﻿@model ProductModel.ProductAttributeMappingModel
@using Grand.Core.Domain.Catalog
@{
    Layout = "~/Areas/Admin/Views/Shared/_AdminPopupLayout.cshtml";
    //page title
    ViewBag.Title = T("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules").Text;

    var attributeControlType = (AttributeControlType)Model.AttributeControlTypeId;
}
<form asp-controller="Product" asp-action="ProductAttributeValidationRulesPopup" enctype="multipart/form-data" method="post"
      asp-route-ProductId="@Context.Request.Query["ProductId"]"
      asp-route-btnId="@Context.Request.Query["btnId"]"
      asp-route-formId="@Context.Request.Query["formId"]">
    
    <div class="row">
        <div class="col-md-12">
            <div class="x_panel light form-fit">
                <div class="x_title">
                    <div class="caption">
                        <i class="fa fa-cubes"></i>
                        @T("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules")
                    </div>
                </div>
                <div class="x_content form">
                    <div class="form-horizontal">
                        <div class="form-body">
                            <div class="form-group" @(attributeControlType != AttributeControlType.TextBox && attributeControlType != AttributeControlType.MultilineTextbox ? Html.Raw("style='display: none;'") : null)>
                                <admin-label asp-for="ValidationMinLength" class="col-sm-3 control-label" />
                                <div class="col-md-9 col-sm-9">
                                    <admin-input asp-for="ValidationMinLength" />
                                    <span asp-validation-for="ValidationMinLength"></span>
                                </div>
                            </div>
                            <div class="form-group" @(attributeControlType != AttributeControlType.TextBox && attributeControlType != AttributeControlType.MultilineTextbox ? Html.Raw("style='display: none;'") : null)>
                                <admin-label asp-for="ValidationMaxLength" class="col-sm-3 control-label" />
                                <div class="col-md-9 col-sm-9">
                                    <admin-input asp-for="ValidationMaxLength" />
                                    <span asp-validation-for="ValidationMaxLength"></span>
                                </div>
                            </div>
                            <div class="form-group" @(attributeControlType != AttributeControlType.FileUpload ? Html.Raw("style='display: none;'") : null)>
                                <admin-label asp-for="ValidationFileAllowedExtensions" class="col-sm-3 control-label" />)
                                <div class="col-md-9 col-sm-9">
                                    <admin-input asp-for="ValidationFileAllowedExtensions" />
                                    <span asp-validation-for="ValidationFileAllowedExtensions"></span>
                                </div>
                            </div>
                            <div class="form-group" @(attributeControlType != AttributeControlType.FileUpload ? Html.Raw("style='display: none;'") : null)>
                                <admin-label asp-for="ValidationFileMaximumSize" class="col-sm-3 control-label" />)
                                <div class="col-md-9 col-sm-9">
                                    <admin-input asp-for="ValidationFileMaximumSize" />
                                    <span asp-validation-for="ValidationFileMaximumSize"></span>
                                </div>
                            </div>
                            <div class="form-group" @(attributeControlType != AttributeControlType.TextBox && attributeControlType != AttributeControlType.MultilineTextbox ? Html.Raw("style='display: none;'") : null)>
                                <admin-label asp-for="DefaultValue" class="col-sm-3 control-label" />
                                <div class="col-md-9 col-sm-9">
                                    <admin-input asp-for="DefaultValue" />
                                    <span asp-validation-for="DefaultValue"></span>
                                </div>
                            </div>
                            <div class="form-actions">
                                <div class="row">
                                    <div class="col-sm-offset-3 col-md-offset-3 col-md-9 col-sm-9">
                                        <button class="btn btn-success" type="submit" name="save"><i class="fa fa-check"></i> @T("Admin.Common.Save") </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    @if (ViewBag.RefreshPage == true)
    {
        <script type="text/javascript">
        try {
            window.opener.document.forms['@(Context.Request.Query["formId"])'].@(Context.Request.Query["btnId"]).click();
        } catch (e) {
        }
        window.close();
        </script>
    }
    @if (!Model.ValidationRulesAllowed)
    {
        <div class="note note-danger">>This attribute type cannot have validation rules</div>
    }
</form>
